package com.guaoran.source.mybatis.execute;

import com.guaoran.source.mybatis.config.Configuration;
import com.guaoran.source.mybatis.config.MapperRegistory;
import com.guaoran.source.mybatis.statement.StatementHandler;
import lombok.Data;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;

/**
 * @author : 孤傲然
 * @Description :
 * @date :2018/5/25 14:12
 */
@Data
public class DefaultExecutor implements Executor{
    private Configuration configuration;

    public DefaultExecutor(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public <T> T selectOne(MapperRegistory.MapperData mapperData, Object parameter) throws SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        StatementHandler statementHandler = new StatementHandler(configuration);
        return statementHandler.query(mapperData,parameter);
    }
}
